<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>


<c:url var="userGrid" value="/user/userGrid" />
<div class="window">
	<div class="window-holder">
		<div class="window-content">
			<div class="breadcrumb green">
				<a href="#" class="active">userGridView</a>
			</div>

			<div id="userGridView" style='margin:auto;' class="pq-grid-holder"></div>
		</div>
	</div>
</div>		

<script>
$(function () {
	var colM = [
					
					{ dataType: "string", width: 100, title:"<spring:message code='label.user.name'/>" , dataIndx: "userName"  ,editable:false},
					{ dataType: "string", width: 100, title:"<spring:message code='label.first.name'/>" , dataIndx: "firstName" ,editable:false},
					{ dataType: "string", width: 100, title:"<spring:message code='label.last.name'/>" , dataIndx: "lastName" ,editable:false},
					{ dataType: "string", width: 100, title:"<spring:message code='label.language.code'/>" , dataIndx: "languageCode" ,editable:false},
					{ dataType: "string", width: 100, title:"<spring:message code='label.user.status'/>" , dataIndx: "userStatus" ,editable:false},
					{ dataType: "string", width: 100, title:"<spring:message code='label.created.by'/>" , dataIndx: "createdBy" ,editable:false},
					{ dataType: "string", width: 100, title:"<spring:message code='label.created.date'/>" , dataIndx: "createdDate" ,editable:false},
					{ dataType: "string", width: 100, title:"<spring:message code='label.email'/>" , dataIndx: "emailId" ,editable:false},
					{ dataType: "string", width: 100, title:"<spring:message code='label.expiry.date'/>" , dataIndx: "expiryDate" ,editable:false}
					
					
				];
    
   
    var dataModel = {
        location: "remote",
        sorting: "remote",
        
        dataType: "JSON",
        method: "GET",
        curPage: 1,
       
        getUrl: function () {
            var sortDir = (this.sortDir == "up") ? "asc" : "desc";
            var sort = ['userName', 'firstName', 'lastName'];
            return { url: "${userGrid}", data: "cur_page=" + this.curPage + "&records_per_page=" + 
                this.rPP + "&sortBy=" + sort[this.sortIndx] + "&dir=" + sortDir };
        },
        getData: function (dataJSON) {
            //var data= 
            	
            return { curPage: dataJSON.curPage, totalRecords: dataJSON.totalRecords, data: dataJSON };                
        }
    };

    var grid1 = $("div#userGridView").pqGrid({width:"auto",height: 400,
        dataModel: dataModel,
        colModel: colM,
        resizable: true,            
        columnBorders: true
        
    });
    //for details
  $.extend(colM[1], {
  render: function (ui) {
      var rowData = ui.rowData;
   
          
          return '<a href="javascript:_loadScreenFor(\'/user/getInputScreen/'+rowData.userId+'\')">' + rowData.userName+'</a>';
     
  }
});
  //for edit
  $.extend(colM[0], {
	  render: function (ui) {
	      var rowData = ui.rowData;
	          return '<a href="javascript:showObjectDetaisl(\'/user/details/'+rowData.userId+'\')">' + rowData.userName+'</a>';
	     
	  }
	});
});
</script>
